package br.unifor.mia.graph.setorcensitario;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class UserInfoId implements Serializable {

	private String userName;
	
	@ManyToOne
	private SectorLink sectorLink;
	
	/**
	 * Default Constructor, used by Hibernate.
	 */
	public UserInfoId() {
		// Default Constructor, used by Hibernate.
	}

	public UserInfoId(String userName, SectorLink sectorLink) {
		super();
		this.userName = userName;
		this.sectorLink = sectorLink;
	}



	public String getUserName() {
		return userName;
	}

	public SectorLink getSectorLink() {
		return sectorLink;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((sectorLink == null) ? 0 : sectorLink.hashCode());
		result = prime * result
				+ ((userName == null) ? 0 : userName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof UserInfoId)) {
			return false;
		}
		UserInfoId other = (UserInfoId) obj;
		if (sectorLink == null) {
			if (other.sectorLink != null) {
				return false;
			}
		} else if (!sectorLink.equals(other.sectorLink)) {
			return false;
		}
		if (userName == null) {
			if (other.userName != null) {
				return false;
			}
		} else if (!userName.equals(other.userName)) {
			return false;
		}
		return true;
	}
}
